$(function () {
    queryNewUserSysMessageList(1);
    updateMessageStatus();
    $('body').on('click','#deleteMessage',function () {
        var _this = $(this);
        var id = _this.data('id');
        var index = layer.open({
            type: 1,
            title: '提示',
            content: '是否删除消息，删除后无法恢复？',
            btn: [' 确 定 ', ' 取 消 '],
            area: 'auto',
            btnAlign: 'c',
            shade: [0.3, '#000000'],
            skin: 'lay_ppComment__wrap',
            yes: function (index) {
                $.ajax({
                    url:baseloaction +'/web/uc/affiche/deleteReceiveAffiche',
                    type:'post',
                    dataType:'json',
                    data:{'id':id},
                    success:function (result) {
                        layer.close(index);
                        icModale(0,"",result.message);
                        if (result.success) {
                            _this.parents('li').remove();
                            if (emptyMessage()) {
                                $('section.no-data__wrap').show();
                            }
                        }
                    },
                    error:function () {
                        icModale(0,"","系统错误，操作失败");
                    }
                });

            },
            btn2: function () {
                layer.close(index);
            }
        });
    });

    function emptyMessage() {
        return $('ul.newsList > li').length == 0;
    }

    function updateMessageStatus() {
        DeleteCookie("messageState");
        $.ajax({
            url:baseloaction +'/web/uc/affiche/updateReceiveAfficheStatus',
            type:'post',
            dataType:'json',
            success:function (result) {
            },
            error:function (error) {
            }
        });
    }
});

function queryNewUserSysMessageList(pageNo) {
    var obj={
        url: baseloaction + '/web/uc/affiche/ajax/queryUserAfficheList',//请求url
        contextId:'user-message-list-box',//请求成功后数据内容添加的地方
        pageNo:pageNo,//页面码，可以不传
        pageCall:queryNewUserSysMessageList,//分页方法（一般调用自身）
        params:'name=aaa&get=xxx',//查询参数
        callback:function (pageNo) {
            /*$('.u-my-course_box').slimScroll({
                height: '100%',
                railOpacity: 0.9,
                alwaysVisible: true
            });*/
        }//查询成功且设置完成数据后的回调方法
    };
    getPageAjaxData(obj);
}